#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
	char ch = '\0';
	char arr[20] = { 0 };
	//打开源文件
	FILE* srcf = fopen("data.txt", "r");
	if (srcf == NULL)
	{
		perror("srcf->fopen");
		return 1;
	}
	//打开目标文件
	FILE* destf = fopen("data_copy.txt", "w");
	if (destf == NULL)
	{
		perror("destf->fopen");
		return 1;
	}
	//拷贝文件
	while ((ch = fgetc(srcf)) != EOF)
	{
		fputc(ch, destf);
	}
	//关闭源文件
	fclose(srcf);
	srcf = NULL;
	//关闭目标文件
	fclose(destf);
	destf = NULL;
	return 0;
}